﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using CXDB;
using SubSonic;
using Coolite.Ext.Web;

/// <summary>
///ApplyAction 的摘要说明
/// </summary>
public class ApplyAction
{
	public ApplyAction()
	{
		//
		//TODO: 在此处添加构造函数逻辑
		//
	}
    public static void Add(Guid g,string reason,string tb)
    { 
        Query q = new Query(CxApply.Schema);
        q.AddWhere("guid", g);
        q.AddWhere("uid",Cookies.getCookies("cuid"));
        q.SetSelectList("bossnod,bosstime");
        IDataReader dr = q.ExecuteReader();
        if (dr.Read())
        {
            if (dr[0].ToString() == "0")
            {
                Err.Warning("已经有申请记录，请等待领导审核通过。", MessageBox.Icon.WARNING);
                return;
            }
        }
        CxApply cx = new CxApply();
        cx.Uid = int.Parse(Cookies.getCookies("cuid"));
        cx.Guid = g;
        cx.Reason = reason;
        cx.CountTimes = 1;
        cx.Status = 0;
        cx.InTime = DateTime.Now;
        cx.BossNod = 0;
        cx.Tbname = tb;
        cx.Save();
        Err.Warning("申请已提交，请等待审核！", MessageBox.Icon.NONE);
    }
}
